/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package co.com.entities;

import java.io.Serializable;
import java.math.BigInteger;
import java.util.Date;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * @author dloaiza
 */
@Entity
@Table(name = "TAB_DESCUBRIDOR")
@NamedQueries({
    @NamedQuery(name = "Descubridor.findAll", query = "SELECT d FROM Descubridor d")})
public class Descubridor implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected DescubridorPK descubridorPK;
    @JoinColumn(name = "DSID_USUARIO", referencedColumnName = "NMDOCUMENTO", nullable = false, insertable = false, updatable = false)
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Usuario usuario;
    @JoinColumn(name = "NMID_ASTEROIDE", referencedColumnName = "NMID_ASTEROIDE", nullable = false, insertable = false, updatable = false)
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Asteroide asteroide;

    public Descubridor() {
    }

    public Descubridor(DescubridorPK descubridorPK) {
        this.descubridorPK = descubridorPK;
    }

    public Descubridor(String dsidUsuario, BigInteger nmidAsteroide, Date fefechaDescubrimiento) {
        this.descubridorPK = new DescubridorPK(dsidUsuario, nmidAsteroide, fefechaDescubrimiento);
    }

    public DescubridorPK getDescubridorPK() {
        return descubridorPK;
    }

    public void setDescubridorPK(DescubridorPK descubridorPK) {
        this.descubridorPK = descubridorPK;
    }

    public Usuario getUsuario() {
        return usuario;
    }

    public void setUsuario(Usuario usuario) {
        this.usuario = usuario;
    }

    public Asteroide getAsteroide() {
        return asteroide;
    }

    public void setAsteroide(Asteroide asteroide) {
        this.asteroide = asteroide;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (descubridorPK != null ? descubridorPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Descubridor)) {
            return false;
        }
        Descubridor other = (Descubridor) object;
        if ((this.descubridorPK == null && other.descubridorPK != null) || (this.descubridorPK != null && !this.descubridorPK.equals(other.descubridorPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "co.com.alexstarkbd.jpa.entities.Descubridor[ descubridorPK=" + descubridorPK + " ]";
    }
    
}
